package circuits;

public class NotOperator extends OperationConstraint implements OperationListener{

	public NotOperator(Operation operand) {
		super(operand);
		operand.addOperationListener(this);
	}
	
	public NotOperator(boolean booleanValue) {
		super(null);
		this.result = ! booleanValue;
	}

	@Override
	protected void getOperandResult() {
		if (this.operand != null){
			super.getOperandResult();
		}
		else{
			this.setResultAndNotifyListeners(this.result);
		}
	}
	
	@Override
	public void onOperationResultObtained(Operation operand) {
		if (operand.result == true){
			this.setResultAndNotifyListeners(false);
		}
		else{
			this.setResultAndNotifyListeners(true);
		}
	}
}
